#ifndef CGEVENTWRAPPER_H
#define CGEVENTWRAPPER_H

#define WAIT_INFINITE G_MAXULONG

class CGEventWrapper
{
public:
  CGEventWrapper();
  CGEventWrapper(gboolean manualReset, gboolean initialState);
  virtual ~CGEventWrapper();

  gboolean Create(gboolean manualReset, gboolean initialState);
  gboolean Destroy();
  gboolean Set();
  gboolean Wait(gulong milis = WAIT_INFINITE);
  gboolean IsSet();
  gboolean Clear();

protected:
  gboolean m_created;       //!< creation flag
  gboolean m_manualReset;   //!< manual reset flag
  gboolean m_initialState;  //!< initial state flag
#if GLIB_CHECK_VERSION(2, 32, 0)
  GMutex m_access;         //!< access to GCond
  GCond m_sig;             //!< the condition
#else
  GMutex *m_access;         //!< access to GCond
  GCond *m_sig;             //!< the condition
#endif
  gboolean m_flag;          //!< signaled flag
};

#endif // CGEVENTWRAPPER_H
